home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / rexxutil.zip / REXTEST1.CMD < prev    next >
OS/2 REXX Batch file  |  1991-03-19  |  8KB  |  312 lines

  1. /*** Rexx Cmd for Testing RexxUtil DLL functions - By David Ashley ***/
  2. /*** Test Cmd for RexxUtil Version 1.00 ***/
  3. trace 'o'
  4. arg opt
  5.  
  6.  
  7. if opt='REXRUNTEST' then do   /* Used when testing RexRun */
  8.   say; say 'Hey, I am easily chaining the RexxUtil exec!'; say
  9.   exit
  10.   end
  11.  
  12.  
  13. if opt='DELETE' then do   /* Used to drop functions */
  14.   call RxFuncDrop('RexCls')
  15.   call RxFuncDrop('RexCopy')
  16.   call RxFuncDrop('RexDelete')
  17.   call RxFuncDrop('RexDir')
  18.   call RxFuncDrop('RexDirExist')
  19.   call RxFuncDrop('RexFileExist')
  20.   call RxFuncDrop('RexGetKey')
  21.   call RxFuncDrop('RexGetVersion')
  22.   call RxFuncDrop('RexPause')
  23.   call RxFuncDrop('RexQCurDisk')
  24.   call RxFuncDrop('RexRead')
  25.   call RxFuncDrop('RexRun')
  26.   call RxFuncDrop('RexSay')
  27.   call RxFuncDrop('RexSearchPath')
  28.   call RxFuncDrop('RexSem')
  29.   call RxFuncDrop('RexSetCurPos')
  30.   call RxFuncDrop('RexSleep')
  31.   call RxFuncDrop('RexUtilVersion')
  32.   call RxFuncDrop('RexWrite')
  33.   exit
  34.   end
  35.  
  36.  
  37. /*** Add each desired function or it won't work ***/
  38. call RxFuncAdd 'RexCls',         'REXXUTIL', 'REXCLS'
  39. call RxFuncAdd 'RexCopy',        'REXXUTIL', 'REXCOPY'
  40. call RxFuncAdd 'RexDelete',      'REXXUTIL', 'REXDELETE'
  41. call RxFuncAdd 'RexDir',         'REXXUTIL', 'REXDIR'
  42. call RxFuncAdd 'RexDirExist',    'REXXUTIL', 'REXDIREXIST'
  43. call RxFuncAdd 'RexFileExist',   'REXXUTIL', 'REXFILEEXIST'
  44. call RxFuncAdd 'RexGetKey',      'REXXUTIL', 'REXGETKEY'
  45. call RxFuncAdd 'RexGetVersion',  'REXXUTIL', 'REXGETVERSION'
  46. call RxFuncAdd 'RexPause',       'REXXUTIL', 'REXPAUSE'
  47. call RxFuncAdd 'RexQCurDisk',    'REXXUTIL', 'REXQCURDISK'
  48. call RxFuncAdd 'RexRead',        'REXXUTIL', 'REXREAD'
  49. call RxFuncAdd 'RexRun',         'REXXUTIL', 'REXRUN'
  50. call RxFuncAdd 'RexSay',         'REXXUTIL', 'REXSAY'
  51. call RxFuncAdd 'RexSearchPath',  'REXXUTIL', 'REXSEARCHPATH'
  52. call RxFuncAdd 'RexSem',         'REXXUTIL', 'REXSEM'
  53. call RxFuncAdd 'RexSetCurPos',   'REXXUTIL', 'REXSETCURPOS'
  54. call RxFuncAdd 'RexSleep',       'REXXUTIL', 'REXSLEEP'
  55. call RxFuncAdd 'RexUtilVersion', 'REXXUTIL', 'REXUTILVERSION'
  56. call RxFuncAdd 'RexWrite',       'REXXUTIL', 'REXWRITE'
  57. say; say 'Functions have now been loaded.'
  58.  
  59.  
  60. /*** Give greetings ***/
  61. call RexCls
  62. say; say 'This is a test exec for RexUtilVersion 'RexUtilVersion()'!'
  63. call RexPause
  64.  
  65.  
  66. /*** Test RexCls ***/
  67. call RexCls; say
  68. call RexPause 'This is a test of RexCls, press any key...'
  69. call RexCls
  70. say; say 'Did you see that quick screen-clear via RexCls?'
  71. call RexPause
  72.  
  73.  
  74. /*** Test RexCurPos ***/
  75. call RexCls
  76. say; say 'This is a test of RexCurPos...'
  77. call RexSetCurPos '3', '0'
  78. call RexPause 'Press a key'
  79. call RexSetCurPos '10', '50'
  80. call RexPause 'Press a key'
  81. call RexSetCurPos '20', '20'
  82. call RexPause 'Press a key'
  83. call RexSetCurPos '5', '65'
  84. call RexPause 'Press a key'
  85. call RexSetCurPos '23', '0'
  86. call RexPause
  87.  
  88.  
  89. /*** Test RexCopy ***/
  90. call RexCls
  91. say; say 'Testing RexCopy by creating the file Rextemp1.fil:'
  92. call RexCopy 'c:\config.sys', 'rextemp1.fil'
  93. call RexPause
  94.  
  95.  
  96. /*** Test RexDelete ***/
  97. call RexCls
  98. say; say 'Testing RexDelete by deleting the file Rextemp.fil:'
  99. say 'Creating file first.'
  100. RexCopy 'c:\config.sys', 'rextemp.fil'
  101. say 'File created, attempting delete.'
  102. call RexPause
  103. if RexDelete('Rextemp.fil')=0 then
  104.   say 'The file Rextemp.fil has been deleted!'
  105. else
  106.   say 'Could not delete Rextemp.fil!'
  107. call RexPause
  108.  
  109.  
  110. /*** Test RexDirExist ***/
  111. call RexCls
  112. say; say 'Testing RexDirExist by seeing if C:\TEMP exists:'
  113. call RexPause
  114. if RexDirExist('c:\temp') then
  115.   say 'Yes, it exists!'
  116. else
  117.   say 'No, it does not exist!'
  118. call RexPause
  119.  
  120.  
  121. /*** Test RexQCurDisk ***/
  122. call RexCls
  123. say; say 'Testing RexQCurDisk by displaying all available drives:'
  124. say RexQCurDisk()
  125. call RexPause
  126.  
  127.  
  128. /*** Test RexFileExist ***/
  129. call RexCls
  130. say; say 'Testing RexFileExist by seeing if REXTEMP.FIL exists:'
  131. say 'Creating file first.'
  132. RexCopy 'c:\config.sys', 'rextemp.fil'
  133. say 'File created, testing existence.'
  134. call RexPause
  135. if RexFileExist('rextemp.fil') then
  136.   say 'Yes, it exists!'
  137. else
  138.   say 'No, it does not exist!'
  139. call RexPause
  140. say 'Now deleting file.'
  141. call RexDelete 'rextemp.fil'
  142. say 'File deleted, testing existence.'
  143. call RexPause
  144. if RexFileExist('rextemp.fil') then
  145.   say 'Yes, it exists!'
  146. else
  147.   say 'No, it does not exist!'
  148. call RexPause
  149.  
  150.  
  151. /*** Test RexGetKey ***/
  152. call RexCls
  153. say; say 'Testing RexGetKey, type a key:'
  154. key = RexGetKey('ECHO')
  155. say; say 'You pressed:  'key
  156. resp=''
  157. say; say; say 'You may use RexGetKey for entering password info!'
  158. say 'Enter a secret password, then press Enter:'
  159. do until c2d(key)=13
  160.   key=RexGetKey('NOECHO')
  161.   resp=resp||key
  162.   end
  163. say 'Hey, you entered:'  resp
  164. call RexPause
  165.  
  166.  
  167. /*** Test RexGetVersion ***/
  168. call RexCls
  169. say; say 'Test of RexGetVersion shows you are running OS/2 version ',
  170. RexGetVersion()
  171. call RexPause
  172.  
  173.  
  174. /*** Test RexRead ***/
  175. call RexCls
  176. say; say 'Testing RexRead by reading in C:\CONFIG.SYS:'
  177. call RexPause
  178. call RexRead 'c:\config.sys', 'file'
  179. say 'The number of lines in the file is' file.0'.'
  180. say 'The listing of the file follows:'
  181. call RexPause
  182. do num=1 to file.0
  183.   say file.num
  184.   end
  185. call RexPause
  186.  
  187.  
  188. /*** Test RexRun ***/
  189. call RexCls
  190. say; say 'Testing RexRun by re-executing (ie chaining) RexTest...'
  191. parse source . . fspec
  192. drive = left(fspec,2)
  193. call RexRun(drive'Rextest.cmd RexRunTest')
  194. call RexPause
  195.  
  196.  
  197. /*** Test RexPause ***/
  198. call RexCls
  199. call RexPause 'You are currently testing RexPause. Strike any key...'
  200.  
  201.  
  202. /*** Test RexSay ***/
  203. call RexCls
  204. say; say 'This is a test of RexSay...'
  205. call RexSay 'Please enter a string > '
  206. resp = linein('STDIN')
  207. say 'Did you notice everything appeared on one line?'
  208. call RexPause
  209.  
  210.  
  211. /*** Test RexSearchPath ***/
  212. call RexCls
  213. say; say 'Testing RexSearchPath by searching for DISPLAY.DLL in LIBPATH:'
  214. call RexPause
  215. say 'Directory containing DISPLAY.DLL is:  ',
  216. RexSearchPath('LIBPATH', 'display.dll')
  217. say; say 'Testing RexSearchPath by searching for CMD.EXE in PATH:'
  218. call RexPause
  219. say 'Directory containing CMD.EXE is:  'RexSearchPath('PATH', 'cmd.exe')
  220. call RexPause
  221.  
  222.  
  223. /*** Test RexSleep ***/
  224. call RexCls
  225. say; say 'Testing RexSleep: Sleeping for 2 seconds...'
  226. call RexSleep '2'
  227. call RexPause
  228.  
  229.  
  230. /*** Test RexUtilVersion ***/
  231. call RexCls
  232. say; say 'Test of RexUtilVersion shows you are using version ',
  233. RexUtilVersion()
  234. call RexPause
  235.  
  236.  
  237. /*** Test RexWrite ***/
  238. call RexCls
  239. say; say 'Testing RexWrite by creating the file Rextemp.fil:'
  240. call RexWrite 'Rextemp.fil', 'file', file.0, , 'r'
  241. call RexPause
  242.  
  243.  
  244. /*** Test RexFileSize ***/
  245. call RexCls
  246. say; say 'Testing RexFileSize by obtaining the size of Rextemp.fil:'
  247. say 'The size of the file is 'RexFileSize('Rextemp.fil')
  248. call RexPause
  249.  
  250.  
  251. /*** Test RexRenameFile ***/
  252. call RexCls
  253. say; say 'Testing RexRenameFile by renaming Rextemp.fil to temp2.fil:'
  254. say 'The return code from RexRenameFile is ',
  255.  RexRenameFile('Rextemp.fil', 'temp2.fil')
  256. call RexPause
  257.  
  258.  
  259. /*** Test RexDir ***/
  260. call RexCls
  261. say; say 'Testing RexDir by reading in C:\*.*:'
  262. call RexPause
  263. call RexDir 'c:\*.*', 'file', 'hsb'
  264. do num=1 to file.0
  265.   say file.num
  266.   end
  267. call RexPause
  268.  
  269.  
  270. /*** Test RexSem ***/
  271. call RexCls
  272. say; say 'This is a test of RexSem...'
  273. say 'Return code of \SEM\RXTEST semaphore ''Create'' =' ,
  274. RexSem('\sem\rxtest', 'CREATE')
  275. say 'Return code of semaphore ''Set'' =' RexSem('\sem\rxtest', 'SET')
  276. say 'Return code of ''Wait for semaphore clear'' =' ,
  277. RexSem('\sem\rxtest', 'WAIT', '1000')
  278. say 'Return code of semaphore ''Clear'' =' RexSem('\sem\rxtest', 'CLEAR')
  279. say 'Return code of ''Wait for semaphore clear'' =' ,
  280. RexSem('\sem\rxtest', 'WAIT', '1000')
  281. say 'Return code of semaphore ''Close'' =' RexSem('\sem\rxtest', 'CLOSE')
  282. call RexPause
  283.  
  284.  
  285. /*** Give Salutations ***/
  286. call RexCls
  287. say; say 'Bye'
  288.  
  289.  
  290. /**** Drop all used functions ****/
  291. call RxFuncDrop('RexCls')
  292. call RxFuncDrop('RexCopy')
  293. call RxFuncDrop('RexDelete')
  294. call RxFuncDrop('RexDir')
  295. call RxFuncDrop('RexDirExist')
  296. call RxFuncDrop('RexFileExist')
  297. call RxFuncDrop('RexGetKey')
  298. call RxFuncDrop('RexGetVersion')
  299. call RxFuncDrop('RexPause')
  300. call RxFuncDrop('RexQCurDisk')
  301. call RxFuncDrop('RexRead')
  302. call RxFuncDrop('RexRun')
  303. call RxFuncDrop('RexSay')
  304. call RxFuncDrop('RexSearchPath')
  305. call RxFuncDrop('RexSem')
  306. call RxFuncDrop('RexSetCurPos')
  307. call RxFuncDrop('RexSleep')
  308. call RxFuncDrop('RexUtilVersion')
  309. call RxFuncDrop('RexWrite')
  310.  
  311. exit
  312.